home *** CD-ROM | disk | FTP | other *** search
- /* PostNews.thor by Tommy Larsen and Troels Walsted Hansen
- ** $VER: PostNews.thor v1.05 (19.03.94)
- **
- ** An ARexx script for parsing News articles from InterNet
- ** and making EnterMsg events for each of the articles.
- */
-
- /* this must be set correctly! */
-
- rxpath = 'THOR:Rexx/'
-
- options results
-
- if(substr(address(),1,4) ~= "THOR") then do
- if ~(show(p, "THOR.01")) then do
- say "No THOR port found!"
- exit
- end
- else portname = "THOR.01"
- end
- else portname = address()
-
- address(portname)
-
- if ~show(l, 'rexxsupport.library') then do
- if ~addlib('rexxsupport.library', 0, -30) then do
- REQUESTNOTIFY TEXT '"Please install rexxsupport.library in your libs: directory"' BT '"_Ok"'
- exit
- end
- end
-
- parse arg dir bbsname
-
- if(dir = "") then do
- REQUESTFILE TITLE '"Select News directory:"' ID '"THOR:"' FP PAT '"#?"'
- if(rc ~= 0|result = "") then exit
- else dir = result
-
- endchar = right(dir,1)
-
- if(endchar ~= ":" & endchar ~= "/") then do
- posi = lastpos("/",dir)
- if(posi = 0) then posi = lastpos(":",dir)
- dir = delstr(dir,posi+1)
- end
- end
-
- if(bbsname = "") then do
- REQUESTLIST BBSLIST
- bbsname = result
- if(rc ~= 0 | bbsname = "RESULT") then exit
- end
- else bbsname = strip(bbsname)
-
- files = showdir(dir, A)
- dirs = "" /* String used for subdirs */
-
- do i=1 to words(files)
- dirs = CheckIfMsg(word(files, i))
- end
-
- if dirs ~= "" then /* If the News dir contained subdirs enter those */
- do i = 1 to words(dirs)
- address command "rx "||rxpath||"PostNews.thor "||word(dirs, i)||' '||bbsname /* Highly unrecommended hack */
- end
-
- PACKEVENTS BBS '"'bbsname'"'
-
- exit
- /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
- CheckIfMsg: /* Determine whether it is in fact a file or a dir */
- parse arg file
- sjekk = finn_type(file)
- if sjekk = 1 & file ~= ".next" then call addmessage(file) /* A file. Add it. */
- if sjekk = 2 then do
- dirs = dirs||' '||checker||'/' /* Add this dir to the list of subdirs */
- end
- return dirs
- /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
- addmessage:
- parse arg messy /* Filename will be used for subject if it isn't found in the file */
-
- subject = finnsubject(dir, messy)
- if subject = 0 then subject = messy
- konf=strip(dir, T, "/") /* A highly insecure way of obtaining the dir name */
- lstpos = lastpos('/', konf)
- konf = substr(konf, lstpos + 1)
-
- select /* Determine conf name based on dir name */
- when upper(konf) = 'AMIGA' then konf = 'csa/sources'
- when upper(konf) = 'ANNOUNCE' then konf = 'csa/announce'
- when upper(konf) = 'REVIEWS' then konf = 'csa/reviews'
- when upper(konf) = 'VITSER' then konf = 'no/vitser'
- when upper(konf) = 'ARTIKLER' then konf = 'ntb/artikler'
- otherwise
- konf = 'Frainternet' /* Default conf name */
- end
-
- abs_file = dir || messy ; abs_file = compress(abs_file) /* Add the event */
- ADDEVENT BBS '"'bbsname'"' EVENT ENTERMSG SENDTO '"ALL"' CONF '"'konf'"' MSGFILE '"'abs_file'"' SUB '"'subject'"'
-
- return 0
- /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
- finnsubject: procedure
- parse arg
- file = arg(1)||arg(2)
-
- if open(fh, file, 'R') then do
- do q=1 to 15 /* Read the first 15 lines of the message */
- subj = readln(fh)
- if upper(word(subj,1)) = 'SUBJECT: ' then do /* Try to extract subject */
- close(fh)
- return(substr(subj,10))
- break
- end
- end
- close(fh)
- end
- else return(0)
- return(0)
- /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
- finn_type: /* Determine whether we are dealing with a file or a dir */
- parse arg checker
- checker=dir||checker
- if word(statef(checker), 1)="DIR" then return 2
- if word(statef(checker), 1)="FILE" then return 1
- else return 0 /* Returns 1 if file and 2 if dir */
- return 0
- /*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
-